package com.guiji.text2video.fastvideo.service.Impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.guiji.text2video.fastvideo.domain.vo.Text2videoJob;
import com.guiji.text2video.fastvideo.domain.vo.Text2videoPoolsStat;
import com.guiji.text2video.fastvideo.mapper.Text2videoComposeTaskMapper;
import com.guiji.text2video.fastvideo.mapper.Text2videoJobMapper;
import com.guiji.text2video.fastvideo.mapper.Text2videoNlpTaskMapper;
import com.guiji.text2video.fastvideo.mapper.Text2videoTtsTaskMapper;
import com.guiji.text2video.fastvideo.service.IText2videoJobService;
import com.guiji.text2video.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author scl
 * @date 2021-05-27
 */
@Service
public class Text2videoJobServiceImpl implements IText2videoJobService
{
    @Autowired
    private Text2videoJobMapper text2videoJobMapper;

    @Autowired
    private Text2videoTtsTaskMapper text2videoTtsTaskMapper;

    @Autowired
    private Text2videoComposeTaskMapper text2videoComposeTaskMapper;

    @Autowired
    private Text2videoNlpTaskMapper text2videoNlpTaskMapper;

    @Override
    public void deleteJobHistoryNlpTTSCompose(String jobId) {
        text2videoComposeTaskMapper.deleteText2videoComposeTaskById(jobId);
        text2videoTtsTaskMapper.deleteText2videoTtsTaskById(jobId);
        text2videoNlpTaskMapper.deleteText2videoNlpTaskById(jobId);
    }

    public List<Text2videoJob> selectErrorJobsByZipId(String zipId){
        return text2videoJobMapper.selectErrorJobsByZipId(zipId);
    };
    /**
     * 查询【请填写功能名称】
     * 
     * @param strings 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public List<Text2videoJob> selectText2videoJobById(ArrayList<String> strings)
    {
        return text2videoJobMapper.selectText2videoJobById(strings);
    }

    @Override
    public Text2videoJob selectText2videoJobByJobId(Text2videoJob text2videoJob) {

        return text2videoJobMapper.selectText2videoJobByJobId(text2videoJob);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param text2videoJob 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<Text2videoJob> selectText2videoJobList(Text2videoJob text2videoJob)
    {
        return text2videoJobMapper.selectText2videoJobList(text2videoJob);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param text2videoJob 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertText2videoJob(Text2videoJob text2videoJob)
    {
        text2videoJob.setCreateTime(DateUtils.getNowDate());
        return text2videoJobMapper.insertText2videoJob(text2videoJob);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param text2videoJob 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateText2videoJob(Text2videoJob text2videoJob)
    {
        text2videoJob.setUpdateTime(DateUtils.getNowDate());
        return text2videoJobMapper.updateText2videoJob(text2videoJob);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteText2videoJobByIds(Long[] ids)
    {
        return text2videoJobMapper.deleteText2videoJobByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteText2videoJobById(String id)
    {
        return text2videoJobMapper.deleteText2videoJobById(id);
    }

    @Override
    public List<Text2videoJob> selectUnCommitTask() {
        return text2videoJobMapper.selectUnCommitTask();
    }

    @Override
    public void insertBylist(List<Text2videoJob> list) {

    }

    @Override
    public void updateMultyStatus(List<Text2videoJob> text2videoJobList) {

    }

    @Override
    public HashMap calculateUncommit() {
        HashMap map = text2videoJobMapper.calculateUncommit();
        HashMap res = new HashMap();
        if(0L==(long)map.get("zip_nums")){
            res.put("zip_nums",0);
            res.put("job_nums",0);
        }else{
            return map;
        }
        return res;
    }

}
